<?php
/**
 * Author: Administrator
 * Date: 2022/7/15 2:15
 */

namespace DesignPatterns\Creation\Builder;


use DesignPatterns\Creation\Builder\Parts\Car;
use DesignPatterns\Creation\Builder\Parts\Door;
use DesignPatterns\Creation\Builder\Parts\Engine;
use DesignPatterns\Creation\Builder\Parts\Vehicle;
use DesignPatterns\Creation\Builder\Parts\Wheel;

class CarBuilder implements BuilderInterface
{
    /**
     * @var Vehicle
     */
    protected $vehicle;

    public function createVehicle() {
        $this->vehicle = new Car();
    }

    public function addDoor() {
        $this->vehicle->addParts('leftDoor', new Door());
        $this->vehicle->addParts('rightDoor', new Door());
    }

    public function addEngine() {
        $this->vehicle->addParts('engine', new Engine());
    }

    public function addWheel() {
        $this->vehicle->addParts('wheelRF', new Wheel());
        $this->vehicle->addParts('wheelLF', new Wheel());
        $this->vehicle->addParts('wheelRB', new Wheel());
        $this->vehicle->addParts('wheelLB', new Wheel());
    }

    public function getVehicle() {
        return $this->vehicle;
    }

}